# Table 1: Descriptive Statistics of Turnout, Salience, and Decision Difficulty


# 1. Load Packages ----

library(tidyverse)
library(stargazer)

# 2. Read in Data ----

load(file = "df_voxit_individual_allrefs.RData")

# 3. Prepare Data ----
# Select the three variables (single propositions)
df_single <- as.data.frame(voxit_complete_salience[voxit_complete_salience$prop_voxit==1,
                         c("turnout", "salience",
                           "difficulty")])

# Select the three variables (multiple propositions)
df_multi <- as.data.frame(voxit_complete_salience[voxit_complete_salience$prop_voxit>1,
                         c("turnout", "salience",
                           "difficulty")])

# 4. Create and Save Table ----
## 4.a Dstats ----
stargazer::stargazer(df_single, df_multi,
                     covariate.labels = c("Turnout", "Salience", "Difficulty"),
                     summary.stat = c("n", "mean", "sd", "min", "max"),
                     summary = T, float = F, digits = 2,
                     out = "Table1.tex")

## 4.b Number of Participants ----
# Voting Days with Single Propositions
length(unique(voxit_complete_salience$id[voxit_complete_salience$prop_voxit==1]))

# Voting Days with Multiple Propositions
length(unique(voxit_complete_salience$id[voxit_complete_salience$prop_voxit>1]))
